package cn.edu.nuc.ssm.dao;

import cn.edu.nuc.ssm.entity.DoList;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface DoListMapper {
    @Delete({
        "delete from do_list",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into do_list (id, use_id, ",
        "acc_id,acc_out_id, do_name, record_date, ",
        "record_money, detail,flag)",
        "values (#{id,jdbcType=INTEGER}, #{useId,jdbcType=INTEGER}, ",
        "#{accId,jdbcType=INTEGER}, #{accOutId,jdbcType=INTEGER},#{doName,jdbcType=VARCHAR}, #{recordDate,jdbcType=CHAR}, ",
        "#{recordMoney,jdbcType=DECIMAL}, #{detail,jdbcType=VARCHAR},#{flag,jdbcType=INTEGER})"
    })
    int insert(DoList record);

    int insertSelective(DoList record);

    @Select({
        "select",
        "id, use_id, acc_id, do_name, record_date, record_money, detail,flag",
        "from do_list",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("cn.edu.nuc.ssm.dao.DoListMapper.BaseResultMap")
    DoList selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(DoList record);

    @Update({
        "update do_list",
        "set use_id = #{useId,jdbcType=INTEGER},",
          "acc_id = #{accId,jdbcType=INTEGER},",
          "do_name = #{doName,jdbcType=VARCHAR},",
          "record_date = #{recordDate,jdbcType=CHAR},",
          "record_money = #{recordMoney,jdbcType=DECIMAL},",
          "detail = #{detail,jdbcType=VARCHAR}",
            "#{flag = flag,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(DoList record);

    /**
     *   按时间查找某一个用户的操作时间
     * @param useId  用户Id
     * @param minRecordDate  开始的时间
     * @param maxRecordDate  结束时间
     * @return  操作记录的时间
     */
    List<DoList> findbyUseIdAndRecordDateBetweenOrEqualTo(@Param("useId")Integer useId, @Param("minRecordDate")String minRecordDate, @Param("maxRecordDate")String maxRecordDate);



}